import pygame
import sys
from init_map import InitMap


class Map(InitMap):
    def __init__(self, *args):
        InitMap.__init__(self)

        self.npc_man = pygame.image.load("../资源/图片/老头.png").convert_alpha()
        self.door_yellow = pygame.image.load("../资源/图片/黄门.jpg").convert_alpha()
        self.door_blue = pygame.image.load("../资源/图片/蓝门.png").convert_alpha()
        self.door_red = pygame.image.load("../资源/图片/红门.jpg").convert_alpha()
        self.hp_blue = pygame.image.load("../资源/图片/蓝药.jpg").convert_alpha()
        self.gem_blue = pygame.image.load("../资源/图片/蓝宝石.jpg").convert_alpha()
        self.gem_red = pygame.image.load("../资源/图片/红宝石.jpg").convert_alpha()
        self.big_feather = pygame.image.load("../资源/图片/大飞羽.png").convert_alpha()
        self.gold_guard = pygame.image.load("../资源/图片/金卫士.png").convert_alpha()
        self.gold_leader = pygame.image.load("../资源/图片/金队长.png").convert_alpha()
        self.dark_guard = pygame.image.load("../资源/图片/冥卫兵.png").convert_alpha()
        self.senior_guard = pygame.image.load("../资源/图片/高级卫兵.png").convert_alpha()
        self.double_sword = pygame.image.load("../资源/图片/双手剑士.png").convert_alpha()
        self.dark_soldier = pygame.image.load("../资源/图片/冥战士.png").convert_alpha()
        self.dark_leader = pygame.image.load("../资源/图片/冥队长.png").convert_alpha()

        self.hero_pos = (1, 10)
        self.up_pos = (5, 10)
        self.down_pos = (0, 10)
        self.variable_pos = {
            (4, 6): (self.npc_man, '13楼老头'),
            (6, 1): (self.door_yellow, '黄门'),
            (9, 10): (self.door_yellow, '黄门'),
            (3, 10): (self.door_blue, '蓝门'),
            (2, 3): (self.door_red, '红门'),
            (0, 3): (self.hp_blue, '蓝药'),
            (4, 9): (self.hp_blue, '蓝药'),
            (10, 6): (self.gem_blue, '蓝宝石'),
            (10, 7): (self.gem_blue, '蓝宝石'),
            (10, 8): (self.gem_blue, '蓝宝石'),
            (8, 4): (self.gem_red, '红宝石'),
            (8, 5): (self.gem_red, '红宝石'),
            (8, 6): (self.gem_red, '红宝石'),
            (7, 10): (self.big_feather, '大飞羽'),
            (0, 4): (self.gold_guard, '金卫士'),
            (0, 6): (self.gold_guard, '金卫士'),
            (1, 8): (self.gold_guard, '金卫士'),
            (0, 5): (self.gold_leader, '金队长'),
            (4, 2): (self.dark_guard, '冥卫兵'),
            (6, 4): (self.dark_guard, '冥卫兵'),
            (6, 6): (self.dark_guard, '冥卫兵'),
            (2, 6): (self.dark_soldier, '冥战士'),
            (4, 4): (self.dark_soldier, '冥战士'),
            (7, 8): (self.dark_soldier, '冥战士'),
            (9, 0): (self.dark_soldier, '冥战士'),
            (3, 5): (self.dark_leader, '冥队长'),
            (8, 10): (self.dark_leader, '冥队长'),
            (6, 5): (self.senior_guard, '高级卫兵'),
            (1, 0): (self.double_sword, '双手剑士'),
        }

    def fixed_brick(self):
        self.draw(self.upstairs, self.up_pos[0], self.up_pos[1])
        self.dic[self.up_pos] = '上楼'
        self.draw(self.downstairs, self.down_pos[0], self.down_pos[1])
        self.dic[self.down_pos] = '下楼'
        for i in range(8):
            self.draw(self.wall, 7, i)
            self.dic[(7, i)] = '墙'
            self.draw(self.wall, 9, i+1)
            self.dic[(9, i+1)] = '墙'
            if i != 0:
                self.draw(self.wall, 1, i)
                self.dic[(1, i)] = '墙'
        for i in [(0, 9), (1, 9), (2, 1), (3, 1), (4, 1), (5, 1), (3, 3), (4, 3), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7),
                  (4, 7), (3, 7), (2, 7), (3, 8), (3, 9), (5, 9), (6, 9), (6, 10), (7, 9), (8, 9), (9, 9)]:
            self.draw(self.wall, i[0], i[1])
            self.dic[(i[0], i[1])] = '墙'
        for i in self.ls:
            self.screen.blit(self.road, i)
            self.dic[(int((i[0]-375)/48), int((i[1]-25)/48))] = '路'
